home *** CD-ROM | disk | FTP | other *** search
/ Java for 3D & VRML Worlds / Java for 3d and VRML Worlds.iso / examples / chap04 / FollowingAgent.wrl < prev    next >
Text File  |  1996-10-14  |  854b  |  46 lines

  1. #VRML V2.0 utf8
  2.  
  3. #
  4. # an agent is always following you.
  5. #
  6.  
  7. # initial viewpoint
  8. Viewpoint{
  9.         position 0 2 0
  10. }
  11.  
  12. DEF PROX_SENSOR ProximitySensor{
  13.         # you are always in the sensor field.
  14.         size 100 100 100
  15. }
  16.  
  17.  
  18. # floor
  19. Transform{
  20.         translation 0 -0.5 0
  21.         children[
  22.         Shape{geometry Box{size 100 0.1 100}}
  23.         ]
  24. }
  25.  
  26. # stable object to make you realize the world coordinate.
  27. Shape{geometry Box{}}
  28.  
  29. # following agent
  30. DEF AGENT Transform{
  31.         children[
  32.         Inline{url "ManDetailed.wrl"}
  33.         ]
  34. }
  35.  
  36. DEF PROX_SCRIPT Script{
  37.         url "FollowingAgent.class"
  38.         eventIn SFVec3f currentPosition
  39.         eventOut SFVec3f setAgentPosition
  40. }
  41.  
  42. ROUTE PROX_SENSOR.position_changed TO PROX_SCRIPT.currentPosition
  43. ROUTE PROX_SCRIPT.setAgentPosition TO AGENT.set_translation
  44.  
  45.  
  46.